package com.hmy.pig.controller;


import com.hmy.pig.domain.HmyPigOut;
import com.hmy.pig.service.PigOutService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhl
 * @descript 描述 猪只出场记录控制类
 * @date 2024-01-29
 */

@RestController
@RequestMapping("/pigOut")
public class HmyPigOutController extends BaseController {
    @Resource
    private PigOutService pigOutService;

    /**
     * 查询猪只出场纪录信息列表
     *
     * @param pigCode      参数一：猪只耳号
     * @param pigOutType  参数二：出场方式
     * @param pigType  参数三：猪只类型
     * @param pigOutTimeStart 参数三：出场开始时间
     * @param pigOutTimeEnd   参数四：出场结束时间
     * @return 返回查询列表
     */
    @RequiresPermissions("hmy:pigOut:list")
    @GetMapping("/list")
    public TableDataInfo list(String pigCode, String pigOutType, String pigType, String pigOutTimeStart, String pigOutTimeEnd)
    {
        startPage();
        List<HmyPigOut> list = pigOutService.selectPigOutList( pigCode,  pigOutType,  pigType,  pigOutTimeStart,  pigOutTimeEnd);
        return getDataTable(list);
    }
    /**
     * @param hmyPigOut
     * @return com.ruoyi.common.core.web.domain.AjaxResult
     * @author ZHL
     * @date 2024/1/29 19:10
     * @description  新增猪只出场记录
     */
    @RequiresPermissions("hmy:pigOut:add")
    @Log(title = "猪只出场记录管理", businessType = BusinessType.INSERT)
    @PostMapping("add")
    public AjaxResult add( @RequestBody HmyPigOut hmyPigOut)
    {

        return toAjax(pigOutService.insertPigOut(hmyPigOut));
    }
    /**
     * 根据pigId获取单个出场记录信息
     *
     * @param pigId
     * @return
     */
    @RequiresPermissions("hmy:pigOut:query")
    @GetMapping("getInfo/{pigId}")
    public AjaxResult selectPigOutByPigId(@PathVariable Long pigId) {
        return AjaxResult.success(pigOutService.selectPigOutByPigId(pigId));
    }
    /**
     * 根据pigBreedId修改出场记录信息
     *
     * @param hmyPigOut
     * @return
     */
    @PostMapping("update")
    @Log(title = "猪只出场记录管理", businessType = BusinessType.UPDATE)
    @RequiresPermissions("hmy:pigOut:update")
    public AjaxResult updatePigOut(@RequestBody HmyPigOut hmyPigOut) {
        return toAjax(pigOutService.updatePigOut(hmyPigOut));

    }

    /**
     * 根据ID删除出场记录信息
     *
     * @param pigIds
     * @return
     */
    @DeleteMapping("del/{pigIds}")
    @RequiresPermissions("hmy:pigOut:del")
    public AjaxResult delPigOutByPigd(@PathVariable Long[] pigIds) {
        return toAjax(pigOutService.deletePigOutByPigIds(pigIds));
    }


}
